/*
 *	Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012. PARP Research Group.
 *	<http://perception.inf.um.es>
 *	University of Murcia, Spain.
 *
 *	This file is part of the QVision library.
 *
 *	QVision is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU Lesser General Public License as
 *	published by the Free Software Foundation, version 3 of the License.
 *
 *	QVision is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU Lesser General Public License for more details.
 *
 *	You should have received a copy of the GNU Lesser General Public
 *	License along with QVision. If not, see <http://www.gnu.org/licenses/>.
 */

/// @file
/// @brief File from the QVision library.
/// @author PARP Research Group. University of Murcia, Spain.

#include <iostream>
#include "qvcpuplot.h"

QVCPUPlot::QVCPUPlot(const QString name, bool decorations, bool autoShow, bool time, int step, QWidget *parent):
	QVPlot(name, decorations, true, true, autoShow, time, step, parent)
	{ }

#ifndef DOXYGEN_IGNORE_THIS
bool QVCPUPlot::linkUnspecifiedInputProperty(QVPropertyContainer *sourceContainer, QString sourcePropName, LinkType linkType)
	{
	QVProcessingBlock* block;
	if((block = dynamic_cast<QVProcessingBlock*>(sourceContainer)) != NULL)
		{
		int propType = block->getPropertyType(sourcePropName);
		int cpusType = QVariant::fromValue(QVStat()).userType();
	
		if (propType != cpusType) {
			std::cerr << "Warning: a cpuplot only can be linked to a QVStat property." << std::endl;
			return false;
			}
		else
			return QVPlot::linkUnspecifiedInputProperty(block, sourcePropName, linkType);
		}
	else
		return false;
	}

QStringList QVCPUPlot::getPropertyCurvNames(QString property) const
	{
	const QVStat stat = getPropertyValue<QVStat>(property);
	return stat.getFlagNames();
	}

QList<double> QVCPUPlot::getPropertyCurvValues(QString property) const
	{
	const QVStat stat = getPropertyValue<QVStat>(property);
	return stat.getLastStats();
	}

QList<int> QVCPUPlot::getPropertyCurvOrders(QString property) const
	{
	const QVStat stat = getPropertyValue<QVStat>(property);
	return stat.getFlagOrder();
	}
#endif
